﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Locator.Inventory;
using DataAccess;
using System.ServiceModel.Activation;
using Inventory.BusinessEntities;
using DataAccess.BusinessEntities;
using Locator.LcboServices.LcboStoresService.Services;
using Locator.LcboServices.PageLoaders.Services;
using Locator.LcboServices.LcboInventoryService.Services;
using System.Threading;
using System.Web;
using DataAccess.Services;

namespace Locator.Services
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class InventoryService : IInventoryService
    {
        public IInventoryController InventoryController { get; set; }

        /// <summary>
        /// Initializes a new instance of the InventoryService class.
        /// </summary>
        public InventoryService()
        {
            this.InventoryController = new InventoryController(
                new LcboInventoryServiceAgent(new LivePageRetrieverFactory()),
                new LcboStoresServiceAgent(new LivePageRetrieverFactory()),
                new LcboDrinkLocatorContext());
            Thread.CurrentPrincipal = HttpContext.Current.User;
        }

        public List<StoreWithInventory> GetInventoriesWithRequest(InventoryRequest request)
        {
            return this.InventoryController.GetInventoriesWithRequest(request);
        }

        public List<Store> GetStoresForCurrentUser()
        {
            return this.InventoryController.GetStoresForCurrentUser();
        }

        public List<ProductListItem> GetProductsForCurrentUser()
        {
            return this.InventoryController.GetProductsForCurrentUser();
        }
    }
}
